package com.project.controller;

import com.project.bean.RepliesBean;
import com.project.bean.UserBean;
import com.project.service.IRepliesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("replies")
public class RepliesController {
    @Autowired
    private IRepliesService service;

    @RequestMapping("add")
    public String add(RepliesBean repliesBean, HttpServletRequest req) {
        UserBean loginUser = (UserBean) req.getSession().getAttribute("loginUser");
        repliesBean.setAuthor(loginUser.getName());
        service.add(repliesBean);
        return "ok";
    }
}
